#pragma once

#include "Base/Tests/Test.Application.h"

#undef  APP_NAME
#define APP_NAME	TestLog
#undef  APP_BASE
#define APP_BASE	TestApp


class APP_NAME : public APP_BASE
{
public:
	APP_NAME (IPlatform *platform, EDevice::type deviceType) :
		APP_BASE( platform, deviceType )
	{
	}

	void OnEnter () override
	{
		DEBUG_CONSOLE( "OnEnter - begin" );

#	ifdef PLATFORM_ANDROID
		ESS()->GetFileSystem()->SetCurrentDirectory( ESS()->GetApplication()->GetPlatform()->GetExternalPath() );
#	endif

		DEBUG_CONSOLE( "Open log" );
		_GetLogger()->Open( "log/log", false );

		Date	time;
		bool	crashed;
		
		DEBUG_CONSOLE( "Check crahes" );

		if ( _GetLogger()->ReadCrashFile( "log/crash_log", crashed, time ) and crashed )
		{
			WARNING( "crashed" );
			_GetLogger()->SendAnEmail();
		}
		
		DEBUG_CONSOLE( "Create crash file" );
		_GetLogger()->CreateCrashFile( "log/crash_log" );

		
		DEBUG_CONSOLE( "Test log" );
		LOG( "debug",	ELog::DEBUG   );
		LOG( "info",	ELog::INFO    );
		LOG( "warning",	ELog::WARN		);
		LOG( "error",	ELog::ERROR   );
		LOG( "fatal",	ELog::FATAL   );
		
		DEBUG_CONSOLE( "OnEnter - end" );
	}
};